package cn.otrue.patienthealthmanager.adapter;

import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;

/**
 * Main界面Fragment的适配器
 * 
 * @author gaojunfeng
 * 
 */
public class MainFragmentPagerAdpater extends FragmentPagerAdapter {

	private List<Fragment> fragmentList;

	public MainFragmentPagerAdpater(FragmentManager fm,
			List<Fragment> fragmentList) {
		super(fm);
		this.fragmentList = fragmentList;
	}

	/**
	 * 得到每个页面
	 */
	@Override
	public Fragment getItem(int arg0) {
		return (fragmentList == null || fragmentList.size() == 0) ? null
				: fragmentList.get(arg0);
	}

	/**
	 * 页面的总个数
	 */
	@Override
	public int getCount() {
		int count = 0;
		if (fragmentList != null) {
			count = fragmentList.size();
		}
		return count;
	}

	@Override
	public int getItemPosition(Object object) {
		return PagerAdapter.POSITION_NONE;
	}
}
